// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   Polygon.java

package com.java4less.rchart.gc;

import java.util.Vector;

// Referenced classes of package com.java4less.rchart.gc:
//			Point, Rectangle

public class Polygon extends Vector
{

	public Polygon()
	{
	}

	public void addPoint(int x, int y)
	{
		super.addElement(new Point(x, y));
	}

	public int getX(int i)
	{
		return ((Point)super.elementAt(i)).x;
	}

	public int getY(int i)
	{
		return ((Point)super.elementAt(i)).y;
	}

	public boolean contains(int x, int y)
	{
		return contains1(x, y);
	}

	private boolean contains1(int x, int y)
	{
		int i = 0;
		int j = 0;
		boolean c = false;
		i = 0;
		for (j = size() - 1; i < size(); j = i++)
			if ((getY(i) <= y && y < getY(j) || getY(j) <= y && y < getY(i)) && x < ((getX(j) - getX(i)) * (y - getY(i))) / (getY(j) - getY(i)) + getX(i))
				c = !c;

		return c;
	}

	private Rectangle calculateRect()
	{
		int MinX = 0xf423f;
		int MinY = 0xf423f;
		int MaxX = 0xfff0bdc1;
		int MaxY = 0xfff0bdc1;
		for (int i = 0; i < size(); i++)
		{
			int x = getX(i);
			MinX = Math.min(MinX, x);
			MaxX = Math.max(MaxX, x);
			int y = getY(i);
			MinY = Math.min(MinY, y);
			MaxY = Math.max(MaxY, y);
		}

		return new Rectangle(MinX, MinY, MaxX - MinX, MaxY - MinY);
	}
}
